// CreateUser.cpp : implementation file
//

#include "stdafx.h"
#include "CreateUser.h"
#ifndef __SecurityProjectDlg

#define __SecurityProjectDlg
	#include "SecurityProjectDlg.h"
#endif

// CCreateUser dialog

IMPLEMENT_DYNAMIC(CCreateUser, CDialog)

CCreateUser::CCreateUser(CWnd* pParent /*=NULL*/)
	: CDialog(CCreateUser::IDD, pParent)
{

}

CCreateUser::CCreateUser(CSecurityProjectDlg* secDlg)
	: CDialog(CCreateUser::IDD, NULL)
{
	this->secDlg = secDlg;
}

CCreateUser::~CCreateUser()
{
}

void CCreateUser::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CCreateUser, CDialog)
	ON_BN_CLICKED(IDOK, &CCreateUser::OnBnClickedOk)
END_MESSAGE_MAP()


// CCreateUser message handlers

void CCreateUser::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	CString username;
	CString password;
	CString description;
	GetDlgItemText(IDC_EDIT_USERNAME,username);
	GetDlgItemText(IDC_EDIT_PASSWORD,password);
	GetDlgItemText(IDC_EDIT_DESCRIPTION,description);
	if(username != _T("") && password != _T(""))
	{
		//Message de create account co cau truc :  AXusernameYpasswordZDescription 
		// X,Y,Z la kick thuoc username,pass,description (co dinh thieu dai X,Y,Z la 2 )
		CString message = _T("A0");
		if(username.GetLength() < 10)
			message += _T("0");
		message += secDlg->ToCString(username.GetLength()) + username;
		if(password.GetLength() < 10)
			message += _T("0");
		message += secDlg->ToCString(password.GetLength()) + password;
		if(description.GetLength() < 10)
			message += _T("0");
		message += secDlg->ToCString(description.GetLength()) + description;

		secDlg->SendMessageToServer(message);
	}
	else
	{
		MessageBox(_T("Phai nhap username va password"));
	}
	
}
